package com.sl.mes.db.service.bd;

import com.github.pagehelper.PageHelper;
import com.sl.mes.db.dao.BdWkMapper;
import com.sl.mes.db.itf.bd.IBdWk;
import com.sl.mes.db.vo.*;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class BdWkService implements IBdWk {
    @Resource
    private BdWkMapper bdWkMapper;

    /**
     * 根据主键查询工作中心
     * @param cwkid
     * @return
     */
    @Override
    public BdWk findById(String cwkid) {
        return bdWkMapper.selectByPrimaryKey(cwkid);
    }

    /**
     * 查询所有的工作中心
     * @param pageNo
     * @param pageSize
     * @return
     */
    @Override
    public List<BdWk> queryAll(Integer pageNo, Integer pageSize) {
        BdWkExample example = new BdWkExample();
        example.or().andDrEqualTo(0);
        PageHelper.startPage(pageNo, pageSize);
        return bdWkMapper.selectByExample(example);
    }

    /**
     * 根据cwkid分类工作中心
     * @param cwkid
     * @param pageNo
     * @param pageSize
     * @return
     */
    @Override
    public List<BdWk> queayAllByCwkId(String cwkid, Integer pageNo, Integer pageSize) {
        BdWkExample example = new BdWkExample();
        BdWkExample.Criteria criteria = example.createCriteria();
        criteria.andCwkidEqualTo(cwkid);
        PageHelper.startPage(pageNo, pageSize);
        return bdWkMapper.selectByExample(example);
    }

    /**
     *
     * @param cwKid
     * @return
     */
    @Override
    public List<BdWk> queryAllById(String cwKid) {
        BdWkExample example=new BdWkExample();
        //example.or().andIdIn(Arrays.asList(pk_psndoc)).andEnabledEqualTo(true).andDeletedEqualTo(false);
        example.or().andCwkidEqualTo(cwKid).andDrEqualTo(0);
        List<BdWk> lstPsnJob=bdWkMapper.selectByExample(example);
        return lstPsnJob;
    }

    @Override
    public List<BdWk> repeatWQuery() {
        BdWkExample bdWkExample=new BdWkExample();
        List<BdWk> bdWkList = bdWkMapper.selectByExample(bdWkExample);
        return bdWkList;
    }

    @Override
    public BdWk findByVwkcode(String vwkcode) {
        BdWkExample example=new BdWkExample();
        example.or().andVwkcodeEqualTo(vwkcode);
        return bdWkMapper.selectOneByExample(example);
    }

    /**
     * 查询所有的炉台
     * @return
     */
    @Override
    public List<BdWk> findAllBdWk() {
        BdWkExample example=new BdWkExample();
        return bdWkMapper.selectByExample(example);
    }

}
